***
*Google Community Mobility**
*****
*Downloaded March 31, 2021
import delimited "HSSC replication data\Public data\Global_Mobility_Report.csv", clear
keep if sub_region_1==""
keep if sub_region_2==""

keep if metro_area==""

ren retail_and_recreation_percent_ch g_retail
ren grocery_and_pharmacy_percent_cha g_grocery
ren parks_percent_change_from_baseli g_park
ren transit_stations_percent_change_ g_transit
ren workplaces_percent_change_from_b  g_work
ren residential_percent_change_from_ g_home

gen time = date(date, "YMD")

ren country_region country
encode country, gen(country_code)

tsset time country_code

forval x=1/6 {
gen l`x'_retail=l`x'.g_retail
gen l`x'_work=l`x'.g_work
}
egen retail_7day=rowmean(g_retail l1_retail l2_retail l3_retail l4_retail l5_retail l6_retail)
egen work_7day=rowmean(g_work l1_work l2_work l3_work l4_work l5_work l6_work)

gen month=month(time)
gen year=year(time)

drop if month>3 & year>=2021
collapse (mean) retail_7day work_7day g_retail g_grocery g_park g_transit g_work g_home, by(country)
save "HSSC replication data\Public data\Google_Mobility_Data_March31_2021.dta", replace


